<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>

		<script type="text/javascript">
			// 使用面向对象思想模拟生活中的继承情况。需要声明父类、子类、属性和相关方法，子类不少于2个，属性不少于5个，方法不少2个。
			function Base(name, type) {
				this.name = name;
				this.type = type;
			}
			//方法：查找和阅读
			Book.prototype.find = function() {
				console.log("find word");
			}

			Book.prototype.read = function() {
				console.log("read");
			}
			//继承

			function F() {} // 1. 创建一个空函数（类）
			F.prototype = Base.prototype; // 

			function Book(name, type, price) {
				Base.call(this, name, type);
				this.price = price;
			}
			Book.prototype = new F();
			Book.prototype.constructor = Book;
			let book1 = new Book("英语词典", "工具类书", "28.8");
			console.log(book1);

			//继承
			function Toy(name, type, materials) {
				Base.call(this, name, type);
				this.materials = materials; //材质
			}
			Toy.prototype = new F();
			Toy.prototype.constructor = Toy;
			let toy1 = new Toy("魔方", "益智", "塑料");
			console.log(toy1);
		</script>
	</body>
</html>
